<include file="Public:mainHeader" />
<script src="__JS_PATH__/jquery-1.8.3.js" type="text/javascript"></script>
<link href="__PUBLIC_PATH__/fancybox/source/jquery.fancybox.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC_PATH__/fancybox/source/jquery.fancybox.js" type="text/javascript"></script>
<link rel="stylesheet" href="__PUBLIC_PATH__/webedito/themes/default/default.css" />
<link rel="stylesheet" href="__PUBLIC_PATH__/webedito/plugins/code/prettify.css" />
<script charset="utf-8" src="__PUBLIC_PATH__/webedito/kindeditor.js"></script>
<script charset="utf-8" src="__PUBLIC_PATH__/webedito/lang/zh_CN.js"></script>
<script charset="utf-8" src="__PUBLIC_PATH__/webedito/plugins/code/prettify.js"></script>
<script>
	KindEditor.ready(function(K) {
		var editor1 = K.create('textarea[name="content"]', {
			cssPath : '__PUBLIC_PATH__/webedito/plugins/code/prettify.css',
			uploadJson : '__PUBLIC_PATH__/webedito/php/upload_json.php',
			fileManagerJson : '__PUBLIC_PATH__/webedito/php/file_manager_json.php',
			allowFileManager : true,
			afterCreate : function() {
				var self = this;
				K.ctrl(document, 13, function() {
					self.sync();
					K('form[name=content]')[0].submit();
				});
				K.ctrl(self.edit.doc, 13, function() {
					self.sync();
					K('form[name=content]')[0].submit();
				});
			}
		});
		prettyPrint();
	});
</script>
<script type="text/javascript">
    $(function(){
        $('#button').click(function(){
            if($('#menuName').val()==''){
                $('#menuName').focus();
                alert('菜的名不成为空');
                return false;
            }
            if($('#select').val()=='选择分类'){
                alert('请选择分类');
                return false;
            }
            if($('#menuPrice').val()==''){
                $('#menuPrice').focus();
                alert('菜的价格不成为空');
                return false;
            }

            if($('#menuCon').val()==''){
                $('#menuCon').focus();
                alert('请写菜的详细做法');
                return false;
            }
        });
    });
    $(document).ready(function() {
        $('.fancybox').fancybox();
	});
	
	function fancyboxClose(){	
		$.fancybox.close(); 
	}
	
	function getImg(imgUrl){
		if(imgUrl){
			$('#menuMa').val(imgUrl);
			$('#menuMaBtn').html('删除素材图片').removeClass().attr('href','javascript:delImg();');
			$('#menuMaShow').attr('src',imgUrl).show();
			$('#fileField').hide();
		}
		fancyboxClose();
	}
	function delImg(){
		$('#menuMa').val('');
		$('#menuMaBtn').html('选择素材图片').attr('href','/index.php/Admin/Menu/getMaterial').addClass('fancybox fancybox.iframe');
		$('#menuMaShow').attr('src','').hide();
		$('#fileField').show();
		$('#recover').show();
	}
	
	function recover(){
		var imgUrl = $('#recoverImgUrl').val();
		getImg(imgUrl);
		$('#recover').hide();
	}
</script>

<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="mart15">
  <tr>
    <td width="4"><img src="__IMG_ADMIN_PATH__/gk1.png" width="4" height="39" /></td>
    <td background="__IMG_ADMIN_PATH__/gk2.png"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="23" class="xtgk2"><img src="__IMG_ADMIN_PATH__/gk_1.png" width="16" height="16" /></td>
        <td class="xtgk1">{$title}菜品</td>
      </tr>
    </table></td>
    <td width="5"><img src="__IMG_ADMIN_PATH__/gk3.png" width="5" height="39" /></td>
  </tr>
</table>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#dca581">
  <tr>
    <td valign="top" bgcolor="#FFFFFF"><form action="{:U(GROUP_NAME.'/Menu/editMenu')}" method="post" enctype="multipart/form-data" name="form1" id="form1">
		<input name="targetid" type="hidden" value="{$m.id}" />
      <table width="95%" id="mytable" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#efddd2" class="mart15 marb15 color333">
        <tr>
          <td align="right" bgcolor="#f5ede6">菜品名称</td>
          <td bgcolor="#FFFFFF"><h1>
              <input type="hidden" value="{$m.id}" name="id"/>
            <input type="text" name="name" id="menuName" class="input1" value="{$m.name}"/>
          </h1></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#F5EDE6">所属分类</td>
          <td bgcolor="#FFFFFF"><label for="select"></label>
            <select name="select" id="select">
              <option >选择分类</option>
                <foreach name="list" item="v">
                    <option <if condition="$m['menutypeid'] eq $v['id']">selected</if> <if condition="$v['parentid'] eq 0"> disabled </if> value="{$v.id}"><b>{$v.html}{$v.name}</b></option>
                </foreach>
            </select></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#F5EDE6">价格</td>
          <td bgcolor="#FFFFFF"><input type="text" name="price" id="menuPrice" class="input1" value="{$m.price}" /></td>
        </tr>
          <tr>
              <td align="right" bgcolor="#F5EDE6">单位(例如：份，盘)</td>
              <td bgcolor="#FFFFFF"><input type="text" name="unit" id="textfield2" class="input1" value="{$m.unit}" /></td>
          </tr>
        <tr  height="230">
          <td align="right" bgcolor="#F5EDE6">上传图片</td>
          <td bgcolor="#FFFFFF"><label for="fileField"></label>
            <input  <if condition="$m['img']"> style=" display:none;" </if> type="file" name="fileField" id="fileField" />
			<img id="menuMaShow" src="{$m.img}" <if condition="!$m['img'] && !$imgee"> style=" display:none;" </if> width="348" height="230"/>
			<input type="hidden" id="menuMa" name='picname' value="{$m.img}"/>
			<input type="hidden" id="recoverImgUrl"  value="{$m.img}"/>
			 <if condition="$m['img']"><div style="margin:20px 0 0 20px;"><a id="recover" style="display:none" href="javascript:recover();" >还原</a><br/><a id="menuMaBtn" href="javascript:delImg();" >删除素材图片</a></div><else /> <div style="margin:20px 0 0 20px;">
			<a class="fancybox fancybox.iframe" id="menuMaBtn" href="/index.php/Admin/Menu/getMaterial" >选择素材图片</a></div>
			</if> 
			</td>
        </tr>
		<tr>
          <td align="right" bgcolor="#F5EDE6">是否推荐</td>
          <td bgcolor="#FFFFFF">
		  	<input <if condition="$m['recommend'] eq 1"> checked </if> type="radio" name="recommend" value="1" />是
			<input <if condition="$m['recommend'] eq 0"> checked </if> type="radio" name="recommend" value="0"  />否
          </td>
        </tr>
        <tr>
          <td align="right" bgcolor="#F5EDE6">详细介绍</td>
          <td bgcolor="#FFFFFF">
            <!--<textarea name="content" id="menuCon" class="input2">{$m.content}</textarea>-->
			<textarea name="content" style="width:700px;height:350px;visibility:hidden;">{$m.content}</textarea>
			</td>
        </tr>
		<tr>
          <td align="right" bgcolor="#F5EDE6">是否发布</td>
          <td bgcolor="#FFFFFF">
		  	<input <if condition="$m['publish'] eq 1"> checked </if> type="radio" name="publish" value="1" />是
			<input <if condition="$m['publish'] eq 0"> checked </if> type="radio" name="publish" value="0"  />否
          </td>
        </tr>
        <tr>
          <td colspan="2" align="center" bgcolor="#FFFFFF" ><input type="submit" id="button" value="提交" class="input10" /></td>
        </tr>
      </table>
    </form></td>
        </tr>
      </table></td>
  </tr>
</table>
<include file="Public:mainFooter" />